<?php
namespace app\common\IBLL;
/**
* 仓库接口
*/
interface RepositoryInterface
{
	
	/**
	* Find data by id
	*
	* @param       $id
	* @param array $columns
	*
	* @return mixed
	*/
	public function getByID($id,$columns = ['*']);
	/**
	* Find data by field and value
	*
	* @param       $field
	* @param       $value
	* @param array $columns
	*
	* @return mixed
	*/
	public function getByField($field, $value,$columns = ['*']);
	/**
	* Find data by OR
	*
	* @param array $where
	*
	* @return model
	*/
	public function whereOR(array $where);
	/**
	* Find data by multiple fields
	*
	* @param array $where
	* @param array $columns
	*
	* @return mixed
	*/
	public function findWhere(array $where, $columns = ['*']);
	/**
	* Find data by multiple fields
	*
	* @param array $where
	* @param array $columns
	*
	* @return mixed
	*/
	public function findWherePage(array $where, $columns = ['*'],$row=10);
	/**
	* Save a new entity in repository
	*
	* @param array $attributes
	*
	* @return mixed
	*/
	public function create(array $attributes);
	/**
	* 保存多笔资料
	*
	* @param array $attributes
	*
	* @return mixed
	*/
	public function saveAll(array $attributes);
	/**
	* Update a entity in repository by id
	*
	* @param array $attributes
	* @param       $id
	*
	* @return mixed
	*/
	public function update(array $attributes, $id);
	/**
	* Update or Create an entity in repository
	*
	* @throws ValidatorException
	*
	* @param array $attributes
	* @param array $values
	*
	* @return mixed
	*/
	public function updateOrCreate(array $attributes, array $values = []);
	/**
	* Delete a entity in repository by id
	*
	* @param $id
	*
	* @return int
	*/
	public function delete($id);
	/**
	* Order collection by a given column
	*
	* @param string $column
	* @param string $direction
	*
	* @return $this
	*/
	public function order($sort);
	/**
	* 关联模型
	*
	* @param string $with
	*
	* @return $this
	*/
	public function with($with);
	/**
	* 关联模型查询
	*
	* @param string $with
	* @param array $where
	*
	* @return $this
	*/
	public function hasWhere($with,$where);

}
